在MATLAB和OpenCV的霍夫变换错误?

您所在的位置:网站首页 霍夫圆变换 opencv 在MATLAB和OpenCV的霍夫变换错误?

在MATLAB和OpenCV的霍夫变换错误?

2023-04-13 21:29| 来源: 网络整理| 查看: 265

本文介绍了在MATLAB和OpenCV的霍夫变换错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 限时送ChatGPT账号..

我一直在使用Matlab和OpenCV/labview在我的应用程序中使用Hough变换,发现对于某些图像,Hough变换明显(一致)给出了错误的线条拟合

I have been using the Hough transform in my application both using Matlab and OpenCV/labview and found that for some images, the hough transform gave an obviously wrong line fit (consistently)

这是测试图像和叠加图像.角度似乎正确,但rho已关闭.

Here are the test and overlayed images. The angle seem right, but the rho is off.

在下面的图像上,您将看到顶部图像试图将一条线拟合到原始图像的左侧,而底部图像试图将一条线拟合到图像的右侧.

On the image below, you will see the top image tries to fit a line to the left side of the original image and the bottom image fits a line to the right side of the image.

在Matlab中,我通过以下方式调用Hough函数

In Matlab, I call the Hough function through

[H1D,theta1D,rho1D] = hough(img_1D_dilate,'ThetaResolution',0.2);

在C ++中,我修剪了OpenCV HoughLines函数,因此最后只剩下了我们要填充累加器的部分.请注意,因为我的theta分辨率为0.2,所以我需要分析900个角度. tabSin和tabCos是在函数之前定义的,因此它们只是角度的正弦和余弦.

in C++, i trimmed the OpenCV HoughLines function so I end up with only the part we are filling the accumulator. Note that because my theta resolution is 0.2, I have 900 angles to analyze. The tabSin and tabCos are defined prior to the function so that they are just a sin and cos of the angle.

请注意,这些例程通常运行良好,但仅在特定情况下,它会按照我所展示的方式进行操作.

Note that these routines generally work well, but just for specific cases it performs the way I have shown.

double start_angle = 60.0; double end_angle = 120.0; double num_theta = 180; int start_ang = num_theta * start_angle/180; int end_ang = num_theta * end_angle/180; int i,j,n,index; for (i = 0;i


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3